home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 23.7 KB | 898 lines | [TEXT/MPS ] |
- /*
- File: CRString.h
-
- Contains: xxx put contents here xxx
-
- Written by: Tim Harnett
-
- Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
-
- Notes:
- • This file contains the definitions for the classes for manageing
- OCE RStrings in the Admin program.
-
- • The primary design goal is that all these classes be binary compatible
- with standard OCE RStrings. This means that taking the address of
- (&crstring) will produce a OCE compatible RStringPtr. But don't do
- this! Except (maybe) because you are lazy. Rather use the defined
- coercion operators so that the compiler will automatically do this.
- For example a DirParamBlock field that is defined to be a RStringPtr
- can be assigned without explicit casting.
-
- CRecordName userName("joe"); // there is a constructor for this
- DirEnumerateGetPB pb;
- pb.userName = recordName; // cast operator defined.
-
- As a matter of fact it is best not use explicit casting anywhere. But rather
- provide cast operators, in this example CRString::operatorRString*() was
- used. If you see a cast be suspicious.
-
- • Because these objects must be binary compatible there must be no virtual methods.
- CRString::Size() and CRString::Sensitivity() virtual methods would have been great,
- Tough! These class definitions are good candidates for C++'s Templates. Because it
- has no virtual methods it is safe to use the accessor methods of the base class
- when you have a CRString*. Be careful not to use Comparison or Assignment methods.
-
- • The CRString class should be considered an abstract base class. Notice that the
- constructor is protected. This means only subclasses have access to it.
-
- • Typically these objects are created on the stack. Thier destructors do not need to
- be called on failures.
-
- • Even though the fields of CRString's are protected. The cast operators will allow
- violations of this hiding.
-
- • CRString
- CRString16 - the smallest CRString you can create.
- CRString256 - the RString that can hold a pascal string, ie. Str255.
- CRecordName - the RString that can hold a OCE record name
- CNetworkName
- CDirectoryName
- CRecordType
- CAttributeType
-
- • The classes are not complete. Implementation is evolutionary. Those operators and
- constructors that have been needed have been implemented. Others will undoubtedly
- be needed.
-
- • About CStr255. Because we do not want to modify MacApp to create a CStr255(CRString*)
- constructor or a CStr255 operator=(CRString*) we do the following. We use CRString
- (unsigned char*) operator of the CRString in combination with the
- CRStr255::operator=(unsigned char*) to copy a CRString to a CSt255. For example
-
- Foo(CStr255& str255)
- {
- CRecordName userName("jane");
- str255 = (unsigned char*) jane; // copies jane to CStr255.
-
- // or
- TRecord* user;
- str255 = (unsigned char*)*user->Name(); // TRecord::Name() returns a CRString*, so we have to
- // dereference it once to apply the operator.
- }
-
- Also the CSRString CStr255& operator allows us to do the following. The compiler
- picks the right cast.
-
- CRecordName name("Joe");
- staticText->SetText(name);
-
- Change History (most recent first):
-
- <7> 2/21/95 TMH metrowerks changes
- <6> 2/17/95 TMH added CRecordType& CRecordType::operator =(StringPtr pstr)
- <5> 1/11/95 TMH made changes for Metroworks compiler
- <4> 10/14/94 TMH adde CDirectoryName assignment operator
- <3> 10/13/94 TMH added CRecordType assigment operator
- <2> 10/11/94 TMH added CRecordType::operator =(char* cstr)
- <1> 9/20/94 TMH Abandon RoadsideRest embrace Mercury
- <17> 1/18/94 EMS Added FormBackwardNameMethod
- <16> 11/12/93 TMH added CRString256 assignment operator
- <15> 11/8/93 TMH some assignmment operators
- <14> 8/2/93 TMH added CRString256 assignment operator
- <13> 6/22/93 EMS Added Strip
- <12> 5/24/93 TMH added assignment operator for CRString256
- <11> 2/25/93 TMH some nil checks and RStringHandle assignment operator
- <10> 2/21/93 EMS Checked in Tim's = operation overload for CRecordName and CAttrubiteType.
- <9> 1/26/93 TMH change length of CRecordName to 64
- <8> 1/14/93 TMH a14 upgrades
- <7> 1/4/93 TMH added CRString::ConvertToNumber()
- <6> 12/30/92 TMH fixe CString256 assignment operator, added CAttribute assignment
- operator
- 12/9/92 EMS Made CRString constructor private !!!!
- <4> 10/29/92 TMH RStringHandle constructors
- <3> 10/15/92 TMH a11 upgrades
- <2> 9/25/92 EMS refined #include'ing of .h files and moved classes, globals etc.
- <1> 9/8/92 TMH The Great Project Restructuring of 1992
- <4> 7/10/92 TMH CRString* constructor for CAttributeType
- <2+> 6/23/92 SMT adding default constructor for CRString
- <2> 6/23/92 TMH fixed bugs in CRecordName constructors and assignment operator.
- 5/28/92 TMH New with A8 upgrades
-
- To Do:
- */
-
-
- #ifndef __CRString__
- #define __CRString__
-
- #ifndef __PACKAGES__
- #include "Packages.h"
- #endif
-
- #ifndef __PascalString__
- #include "PascalString.h"
- #endif
-
-
- //-- OCE Includes
-
- #ifndef __OCE__
- #include "OCE.h"
- #endif
-
-
-
- const short kDefaultCharSet = 0;
- const short kCRStringBaseBodySize = 2;
-
-
-
- //-----------------------------
- // C R S t r i n g
- //-----------------------------
-
-
-
-
- class CRString {
- protected:
- // Constructor
- CRString();
- CRString(short charSet);
-
- public:
- unsigned short fCharSet;
- unsigned short fBodyLength;
- unsigned char fBody[kCRStringBaseBodySize];
-
-
- public:
- // Accessors
-
- unsigned short CharSet() const { return fCharSet; };
- unsigned short Length() const;
- unsigned short BodyLength() const;
- Boolean IsEmpty() const;
- Boolean IsNil() const;
- void* Copy(void* destBuf) const; // permits copying into any arbitrary buffer.
- void* CopyBody(void* destBuf) const;
-
- // Cast Operators
-
- operator unsigned char*() const;
- operator const void*() const;
- operator const RString*() const;
- operator RString*();
- operator const unsigned char*();
- operator const CStr255&() const;
- operator CStr255&();
-
- long ConvertToNumber();
-
- void Strip( char theChar, Boolean stripAll, Boolean stripLeading, Boolean stripTrailing );
-
- // Comparisons
-
- friend inline Boolean operator==(const CRString& s1, const CRString& s2);
- friend inline Boolean operator==(const CRString& s1, const RString* s2);
-
-
- };
-
-
- // Accessors
- inline unsigned short CRString::BodyLength() const { return fBodyLength; };
- inline unsigned short CRString::Length() const { return fBodyLength+sizeof(ProtoRString); };
- inline Boolean CRString::IsEmpty() const { return fBodyLength == 0; };
- inline Boolean CRString::IsNil() const { return this == 0; }; // bit'o sleaze
- inline void* CRString::Copy(void* destBuf) const { BlockMove(this,destBuf,this->Length()); return destBuf; };
- inline void* CRString::CopyBody(void* destBuf) const { BlockMove(fBody,destBuf,this->fBodyLength); return destBuf; };
-
- // Cast Operators
- inline CRString::operator const void*() const { return this; };
- inline CRString::operator unsigned char*() const { return (unsigned char*) (fBody - 1); };
- inline CRString::operator const CStr255&() const { return (const CStr255&) *(fBody - 1); };
- inline CRString::operator CStr255&() { return (CStr255&) *(fBody - 1); }
- inline CRString::operator const RString*() const { return (const RString*) this; };
- inline CRString::operator RString*() { return (RString*) this; };
-
-
- // Comparisons
- inline Boolean operator==(const CRString& s1, const CRString& s2)
- { return OCERelRString(&s1, (const RString*)s2, kOCEGenericSensitive) == 0; };
-
- inline Boolean operator==(const CRString& s1, const RString* s2)
- { return OCERelRString( &s1, s2, kOCEGenericSensitive) == 0; };
-
- inline long CRString::ConvertToNumber() { long number = 0; StringToNum((CStr255&)*this,&number); return number; }
-
- //----------------------------
- // C R S t r i n g 1 6
- //----------------------------
-
-
- #define kRString16BodySize 16
-
- class CRString16 : public CRString {
- private:
- unsigned char fData[kRString16BodySize-kCRStringBaseBodySize];
- public:
-
- // Constructors
-
- CRString16();
- CRString16(const char* str,short charSet = kDefaultCharSet);
- CRString16(const RString* rstr);
- CRString16(const RStringHandle rstr);
- CRString16(const CStr255& cstr255,short charSet = kDefaultCharSet);
-
-
- };
-
- //----------------------------
- // C R S t r i n g 3 2
- //----------------------------
-
-
- #define kRString32BodySize 32
-
- class CRString32 : public CRString {
- private:
- unsigned char fData[kRString32BodySize-kCRStringBaseBodySize];
- public:
-
- // Constructors
-
- CRString32();
- CRString32(const char* str,short charSet = kDefaultCharSet);
- CRString32(const RString* rstr);
- CRString32(const RStringHandle rstr);
-
- // Assignment Operators
-
-
- CRString32(const CStr255& cstr255,short charSet = kDefaultCharSet);
- CRString32& operator =(const RString* rstr);
- CRString32& operator =(const char* cstr);
- CRString32& operator =(StringPtr cstr);
-
- };
-
- inline CRString32::CRString32() : CRString () {};
-
- inline CRString32& CRString32::operator =(const char *cstr)
- {
- fCharSet = kDefaultCharSet;
-
- if( cstr != 0 ) {
-
- fBodyLength = strlen(cstr);
- if( fBodyLength > kRString32BodySize )
- fBodyLength = kRString32BodySize;
- memcpy(fBody,cstr,fBodyLength);
- }
- return *this;
- };
-
- inline CRString32& CRString32::operator =(StringPtr pstr)
- {
- fCharSet = kDefaultCharSet;
- if( pstr != 0 ) {
- fBodyLength = pstr[0];
- if( fBodyLength > kRString32BodySize )
- fBodyLength = kRString32BodySize;
-
- memcpy(fBody,&pstr[1],fBodyLength);
- }
- return *this;
- };
-
-
- inline CRString32& CRString32::operator =(const RString* rstr)
- {
- if( rstr != 0 ) {
- fBodyLength = rstr->dataLength;
- if( fBodyLength > kRString32BodySize )
- fBodyLength = kRString32BodySize;
-
- fCharSet = rstr->charSet;
- BlockMove((Ptr)rstr->body,(Ptr) fBody,fBodyLength);
- }
- return *this;
- };
-
- //-----------------------------
- // C R S t r i n g 2 5 6
- //-----------------------------
-
-
-
- #define kRString256BodySize kRStringMaxBytes
-
- class CRString256 : public CRString {
- private:
- unsigned char fData[kRString256BodySize-kCRStringBaseBodySize];
- public:
- // Constructor
-
- CRString256();
- CRString256(const char* str,short charSet = kDefaultCharSet);
- CRString256(const RString* rstr);
- CRString256(const RStringHandle);
- CRString256(const CStr255& cstr255,short charSet = kDefaultCharSet);
-
- // Assignment
- CRString256& operator =(const RString* rstr);
- CRString256& operator =(const RStringHandle rstrH);
- CRString256& operator =(const CStr255& cstr);
- CRString256& operator =(const CRString256& rstr);
- CRString256& operator =(CRString256& rstr);
- CRString256& operator =(const char* cstr);
- CRString256& operator =(StringPtr cstr);
-
- };
-
- // Constructor
- inline CRString256::CRString256() : CRString() {};
-
- // Assignment
- inline CRString256& CRString256::operator =(const RString* rstr)
- {
- if( rstr != 0 ) {
- fBodyLength = rstr->dataLength;
- if( fBodyLength > kRString256BodySize )
- fBodyLength = kRString256BodySize;
-
- fCharSet = rstr->charSet;
- BlockMove((Ptr)rstr->body,(Ptr) fBody,fBodyLength);
- }
- return *this;
- };
-
- // Assignment
- inline CRString256& CRString256::operator =(const CRString256& rstr)
- {
- BlockMove(rstr,(void*)this,rstr.Length());
- return *this;
- }
- inline CRString256& CRString256::operator =(CRString256& rstr)
- {
- BlockMove(rstr,(void*)this,rstr.Length());
- return *this;
- }
-
- inline CRString256& CRString256::operator =(const RStringHandle rstrH)
- {
- if( rstrH != 0 ) {
- fBodyLength = (*rstrH)->dataLength;
- if( fBodyLength > kRString256BodySize )
- fBodyLength = kRString256BodySize;
-
- fCharSet = (*rstrH)->charSet;
- BlockMove((Ptr)(*rstrH)->body,(Ptr) fBody,fBodyLength);
- }
- return *this;
- };
-
-
- inline CRString256& CRString256::operator =(const CStr255& cstr)
- {
- fCharSet = kDefaultCharSet;
- fBodyLength = cstr.Length();
- memcpy(fBody,&cstr.fStr[1],fBodyLength);
- return *this;
- };
-
- inline CRString256& CRString256::operator =(StringPtr pstr)
- {
- fCharSet = kDefaultCharSet;
- if( pstr != 0 ) {
- fBodyLength = pstr[0];
- if( fBodyLength > kRString256BodySize )
- fBodyLength = kRString256BodySize;
-
- memcpy(fBody,&pstr[1],fBodyLength);
- }
- return *this;
- };
-
-
- inline CRString256& CRString256::operator =(const char *cstr)
- {
- fCharSet = kDefaultCharSet;
-
- if( cstr != 0 ) {
-
- fBodyLength = strlen(cstr);
- if( fBodyLength > kRString256BodySize )
- fBodyLength = kRString256BodySize;
- memcpy(fBody,cstr,fBodyLength);
- }
- return *this;
- };
-
-
- //---------------------------------------------
- // C D i r e c t o r y N a m e
- //--------------------------------------------
-
-
- #define kDirectoryNameBodySize kDirectoryNameMaxBytes
-
- class CDirectoryName : public CRString {
- private:
- unsigned char fData[kDirectoryNameBodySize-kCRStringBaseBodySize];
- public:
- CDirectoryName();
- CDirectoryName(const char* str,short charSet = kDefaultCharSet);
- CDirectoryName(const RString* rstr);
- CDirectoryName(const CRString* crstr);
- CDirectoryName(const CStr255& cstr255,short charSet = kDefaultCharSet);
-
- CStr255& operator =(CStr255& pstr);
-
- // Coercion
- operator DirectoryName*();
-
- // Comparisons
- friend inline Boolean operator==(const CDirectoryName& s1, const CDirectoryName& s2);
- friend inline Boolean operator==(const CDirectoryName& s1, const RString* s2);
-
-
- // assignments operators
- CDirectoryName& operator =(const char *cstr);
- CDirectoryName& operator =(StringPtr pstr);
- CDirectoryName& operator =(CDirectoryName& crName);
-
- };
-
- // Constructors
- inline CDirectoryName::CDirectoryName(const CRString* crstr)
- {
- fBodyLength = crstr->BodyLength();
-
- if( fBodyLength > kDirectoryNameBodySize )
- fBodyLength = kDirectoryNameBodySize;
-
- memcpy(this,crstr,sizeof(ProtoRString)+fBodyLength);
-
- }
-
- inline CDirectoryName& CDirectoryName::operator =(CDirectoryName& dirName)
- {
- BlockMove(&dirName,(Ptr) this,dirName.Length());
- return *this;
-
- };
-
- inline CDirectoryName& CDirectoryName::operator =(const char *cstr)
- {
- fCharSet = kDefaultCharSet;
- fBodyLength = 0;
- if( cstr != 0 ) {
- fBodyLength = strlen(cstr);
-
- if( fBodyLength > kDirectoryNameBodySize )
- fBodyLength = kDirectoryNameBodySize;
-
- memcpy(fBody,cstr,fBodyLength);
- }
- return *this;
- };
-
-
- inline CStr255& CDirectoryName::operator =(CStr255& pstr)
- {
- fCharSet = kDefaultCharSet;
- fBodyLength = 0;
- memcpy(pstr.fStr,(unsigned char*) this,fBodyLength+1);
- return pstr;
- };
-
-
- inline CDirectoryName& CDirectoryName::operator =(StringPtr pstr)
- {
- fCharSet = kDefaultCharSet;
- fBodyLength = 0;
-
- if( pstr != 0 ) {
- fBodyLength = pstr[0];
- if( pstr[0] > kDirectoryNameBodySize )
- fBodyLength = kDirectoryNameBodySize;
-
- memcpy(fBody,&pstr[1],fBodyLength);
- }
-
- return *this;
- };
-
-
-
- inline CDirectoryName::CDirectoryName() { fCharSet = kDefaultCharSet; fBodyLength = 0; };
-
- // == operators
-
- inline Boolean operator==(const CDirectoryName& s1, const CDirectoryName& s2)
- { return OCERelRString(&s1, (const RString*)s2, kOCEDirName) == 0; };
-
- inline Boolean operator==(const CDirectoryName& s1, const RString* s2)
- { return OCERelRString( &s1, s2, kOCEDirName) == 0; };
-
- // Coercion
- inline CDirectoryName::operator DirectoryName*() { return (DirectoryName*) this; };
-
-
- //-------------------------------------
- // C R e c o r d N a m e
- //-------------------------------------
-
-
- #define kRecordNameBodySize 64 // Note : 64 is the ADAS limit for a record name, other non-ADAS directories can have longer names.
- //#define kRecordNameBodySize kRStringMaxBytes
-
- class CRecordName : public CRString {
- private:
- unsigned char fData[kRecordNameBodySize-kCRStringBaseBodySize];
- public:
- CRecordName();
- CRecordName(const char* str,short charSet = kDefaultCharSet);
- CRecordName(const RString* rstr);
- CRecordName(const RStringHandle rstr);
- CRecordName(const CRString* crstr);
- CRecordName(CRString16& crstr16);
- CRecordName(const CStr255& cstr255,short charSet = kDefaultCharSet);
-
- // Assignment
-
- CStr255& operator =(CStr255& pstr);
- CRecordName& operator =(const RString* rstr);
- CRecordName& operator =(CRecordName& crName);
- CRecordName& operator =(char* cstr);
- CRecordName& operator =(StringPtr pstr);
- // Comparisons
-
- friend inline Boolean operator==(const CRecordName& s1, const CRecordName& s2);
- friend inline Boolean operator==(const CRecordName& s1, const RString* s2);
-
- Boolean FormBackwardString( CRecordName&, Boolean failMultipleBreaks = false );
-
- };
-
- // Constructors
-
-
- // Assignment
-
- inline CRecordName& CRecordName::operator =(CRecordName& crName)
- {
- BlockMove(&crName,(Ptr) this,crName.Length());
- return *this;
-
- };
-
- inline CStr255& CRecordName::operator =(CStr255& pstr)
- {
- fCharSet = kDefaultCharSet;
- memcpy((unsigned char*)fBody, (unsigned char *)&pstr.fStr[1], pstr.fStr[0]); //can't overflow!
- fBodyLength = pstr.fStr[0];
- // memcpy(pstr.fStr,(unsigned char*) this,fBodyLength+1);
- return pstr;
- };
-
- inline CRecordName& CRecordName::operator =(char* cstr)
- {
- fCharSet = kDefaultCharSet;
-
- short slen = strlen(cstr);
- if( slen > kRecordNameBodySize )
- slen = kRecordNameBodySize;
-
- memcpy(fBody,cstr,slen);
-
- fBodyLength = slen;
-
- return *this;
- };
-
-
- inline CRecordName& CRecordName::operator =(StringPtr pstr)
- {
- fCharSet = kDefaultCharSet;
- fBodyLength = 0;
-
- if( pstr != 0 ) {
- fBodyLength = pstr[0];
- if( fBodyLength > kRecordNameBodySize )
- fBodyLength = kRecordNameBodySize;
-
- memcpy(fBody,&pstr[1],fBodyLength);
- }
-
- return *this;
- };
-
-
- // == operators
-
- inline Boolean operator==(const CRecordName& s1, const CRecordName& s2)
- { return OCERelRString(&s1, (const RString*)s2, kOCERecordOrDNodeName) == 0; };
-
- inline Boolean operator==(const CRecordName& s1, const RString* s2)
- { return OCERelRString( &s1, s2, kOCERecordOrDNodeName) == 0; };
-
-
-
- //-----------------------------
- // C N e t w o r k N a m e
- //-----------------------------
-
-
-
-
- #define kNetworkNameBodySize kNetworkSpecMaxBytes
-
- class CNetworkName : public CRecordName { // Derived from CRecordName because we it IS the name of arecord.
- private:
- unsigned char fData[kNetworkNameBodySize-kCRStringBaseBodySize];
- public:
- CNetworkName();
- CNetworkName(const char* str,short charSet = kDefaultCharSet);
- CNetworkName(const RString* rstr);
- CNetworkName(const CRString* crstr);
- CNetworkName(const CStr255& cstr255,short charSet = kDefaultCharSet);
-
-
- // Assignment
- CStr255& operator =(CStr255& pstr);
-
- // Coercion
- operator NetworkSpec*();
-
-
- // Comparisons
- friend inline Boolean operator==(const CNetworkName& s1, const CNetworkName& s2);
- friend inline Boolean operator==(const CNetworkName& s1, const RString* s2);
-
-
- };
-
- // Assignment
- inline CStr255& CNetworkName::operator =(CStr255& pstr)
- {
- fCharSet = kDefaultCharSet;
- memcpy(pstr.fStr,(unsigned char*) this,fBodyLength+1);
- return pstr;
- };
-
-
- inline CNetworkName::CNetworkName() { fCharSet = kDefaultCharSet; fBodyLength = 0; };
-
- // Coercion
-
- inline CNetworkName::operator NetworkSpec*() { return (NetworkSpec*) this; };
-
- // == operators
-
- inline Boolean operator==(const CNetworkName& s1, const CNetworkName& s2)
- { return OCERelRString(&s1, (const RString*)s2, kOCENetworkSpec) == 0; };
-
- inline Boolean operator==(const CNetworkName& s1, const RString* s2)
- { return OCERelRString( &s1, s2, kOCENetworkSpec) == 0; };
-
-
-
-
- //-----------------------------
- // C R e c o r d T y p e
- //-----------------------------
-
-
-
- #define kRecordTypeBodySize kRString32Size
-
- class CRecordType : public CRString {
- private:
- unsigned char fData[kRecordTypeBodySize-kCRStringBaseBodySize];
- public:
-
- // Constructors
- CRecordType();
- CRecordType(const char* str,short charSet = kDefaultCharSet);
- CRecordType(const RString* rstr);
- CRecordType(const RStringHandle rstr);
- CRecordType(const CRString* crstr);
- CRecordType(const CStr255& cstr255,short charSet = kDefaultCharSet);
- CRecordType(short indRecTypeNum);
-
- // Assignment
- CStr255& operator =(CStr255& pstr);
- CRecordType& operator =(const RString* rstr);
- CRecordType& operator =(CRecordType& crName);
- CRecordType& operator =(char* cstr);
- CRecordType& operator =(StringPtr pstr);
-
- // Comparisons
- friend inline Boolean operator==(const CRecordType& s1, const CRecordType& s2);
- friend inline Boolean operator==(const CRecordType& s1, const RString* s2);
- friend inline Boolean operator!=(const CRecordType& s1, const CRecordType& s2);
- friend inline Boolean operator!=(const CRecordType& s1, const RString* s2);
-
- };
-
-
- // Constructors
- inline CRecordType::CRecordType() { fCharSet = kDefaultCharSet; fBodyLength = 0; };
-
-
- // Assignment
-
- inline CRecordType& CRecordType::operator =(CRecordType& crType)
- {
- BlockMove(&crType,(Ptr) this,crType.Length());
- return *this;
-
- };
-
-
- inline CStr255& CRecordType::operator =(CStr255& pstr)
- {
- fCharSet = kDefaultCharSet;
- memcpy(pstr.fStr,(unsigned char*) this,fBodyLength+1);
- return pstr;
- };
-
-
- inline CRecordType& CRecordType::operator =(char* cstr)
- {
- fCharSet = kDefaultCharSet;
-
- short slen = strlen(cstr);
- if( slen > kRecordTypeBodySize )
- slen = kRecordTypeBodySize;
-
- memcpy(fBody,cstr,slen);
-
- fBodyLength = slen;
-
- return *this;
- }
- inline CRecordType& CRecordType::operator =(StringPtr pstr)
- {
- fCharSet = kDefaultCharSet;
- fBodyLength = 0;
-
- if( pstr != 0 ) {
- fBodyLength = pstr[0];
- if( fBodyLength > kRecordTypeBodySize )
- fBodyLength = kRecordTypeBodySize;
-
- memcpy(fBody,&pstr[1],fBodyLength);
- }
-
- return *this;
- };
-
-
-
- // Constructors
- inline CRecordType::CRecordType(short indRecTypeNum) { *this = OCEGetIndRecordType(indRecTypeNum); };
-
-
-
- // Comparisons
- inline Boolean operator==(const CRecordType& s1, const CRecordType& s2)
- { return OCERelRString(&s1, (const RString*)s2, kOCERecordType) == 0; };
-
- inline Boolean operator==(const CRecordType& s1, const RString* s2)
- { return OCERelRString( &s1, s2, kOCERecordType) == 0; };
-
-
- inline Boolean operator!=(const CRecordType& s1, const CRecordType& s2)
- { return OCERelRString(&s1, (const RString*)s2, kOCERecordType) != 0; };
-
- inline Boolean operator!=(const CRecordType& s1, const RString* s2)
- { return OCERelRString( &s1, s2, kOCERecordType) != 0; };
-
-
-
- //-----------------------------
- // C A t t r i b u t e T y p e
- //-----------------------------
-
-
-
- #define kAttributeTypeBodySize kAttributeTypeMaxBytes
-
- class CAttributeType : public CRString {
- private:
- unsigned char fData[kAttributeTypeBodySize-kCRStringBaseBodySize];
- public:
- CAttributeType();
- CAttributeType(const char* str,short charSet = kDefaultCharSet);
- CAttributeType(const RString* rstr);
- CAttributeType(const RStringHandle rstr);
- CAttributeType(const CRString* crstr);
- CAttributeType(const CStr255& cstr255,short charSet = kDefaultCharSet);
-
- CStr255& operator =(CStr255& pstr);
- CAttributeType& operator =(char* cstr);
- CAttributeType& operator =(const RString* rstr);
- CAttributeType& operator =(CAttributeType& crName);
-
- // Coercion
- operator AttributeType*();
-
-
- // Comparisons
- friend inline Boolean operator==(const CAttributeType& s1, const CAttributeType& s2);
- friend inline Boolean operator==(const CAttributeType& s1, const RString* s2);
-
- };
-
-
- inline CAttributeType& CAttributeType::operator =(CAttributeType& attrType)
- {
- BlockMove(&attrType,(Ptr) this,attrType.Length());
- return *this;
-
- };
-
-
- inline CStr255& CAttributeType::operator =(CStr255& pstr)
- {
- fCharSet = kDefaultCharSet;
- memcpy(pstr.fStr,(unsigned char*) this,fBodyLength+1);
- return pstr;
- };
-
- // Assignment
- inline CAttributeType& CAttributeType::operator =(const RString* rstr)
- {
- memcpy(this,rstr,rstr->dataLength+sizeof(ProtoRString));
- return *this;
- };
-
- inline CAttributeType& CAttributeType::operator =(char* cstr)
- {
- fCharSet = kDefaultCharSet;
-
- short slen = strlen(cstr);
- if( slen > kAttributeTypeBodySize )
- slen = kAttributeTypeBodySize;
-
- memcpy(fBody,cstr,slen);
-
- fBodyLength = slen;
-
- return *this;
- };
-
- inline CAttributeType::CAttributeType() { fCharSet = kDefaultCharSet; fBodyLength = 0; };
-
- // Coercion
-
- inline CAttributeType::operator AttributeType*() { return (AttributeType*) this; };
-
- // == operators
-
- inline Boolean operator==(const CAttributeType& s1, const CAttributeType& s2)
- { return OCERelRString(&s1, (const RString*)s2, kOCEAttrType) == 0; };
-
- inline Boolean operator==(const CAttributeType& s1, const RString* s2)
- { return OCERelRString( &s1, s2, kOCEAttrType) == 0; };
-
-
-
- #endif __CRSTRING__
-